package com.todo.sight.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.sight.application.backend.service.CityInfoBackendService;
import com.todo.sight.application.iface.backend.CityInfoBackendIface;
import com.todo.sight.application.iface.backend.request.*;
import com.todo.sight.application.iface.backend.response.CityInfoDetailResp;
import com.todo.sight.application.iface.backend.response.QueryCityInfoByConditionResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/16 13:56
 * @description
 */
@RestController
@RequestMapping("/bd/city")
@Tag(name = "景点城市后台处理类", description = "景点城市后台处理类")
public class CityInfoBackendController implements CityInfoBackendIface {

    @Resource
    private CityInfoBackendService cityInfoBackendService;


    @Override
    @Operation(summary = "新增城市信息")
    @PostMapping("/insertCityInfo")
    public BizResponse<Boolean> insertCityInfo(@RequestBody InsertCityInfoReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return cityInfoBackendService.insertCityInfo(req);
    }

    @Override
    @Operation(summary = "根据主键更新城市信息")
    @PostMapping("/updateCityInfoById")
    public BizResponse<Boolean> updateCityInfoById(@RequestBody UpdateCityInfoReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return cityInfoBackendService.updateCityInfoById(req);
    }

    @Override
    @Operation(summary = "根据主键删除城市信息")
    @PostMapping("/removeCityInfoById")
    public BizResponse<Boolean> removeCityInfoById(@RequestBody RemoveCityInfoByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return cityInfoBackendService.removeCityInfoById(req);
    }

    @Override
    @Operation(summary = "启禁用城市信息")
    @PostMapping("/enableCityInfoById")
    public BizResponse<Boolean> enableCityInfoById(@RequestBody EnableCityInfoByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return cityInfoBackendService.enableCityInfoById(req);
    }

    @Override
    @Operation(summary = "根据主键查询城市信息")
    @PostMapping("/queryCityInfoById")
    public BizResponse<CityInfoDetailResp> queryCityInfoById(@RequestBody QueryCityInfoByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return cityInfoBackendService.queryCityInfoById(req);
    }

    @Override
    @Operation(summary = "多条件查询城市信息列表")
    @PostMapping("/queryCityInfoByCondition")
    public BizPageResponse<QueryCityInfoByConditionResp> queryCityInfoByCondition(@RequestBody QueryCityInfoByConditionReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return cityInfoBackendService.queryCityInfoByCondition(req);
    }

    @Override
    @Operation(summary = "批量excel倒入")
    @PostMapping("/batchInsertByExcel")
    public BizResponse<Long> batchInsertByExcel(@RequestBody MultipartFile file) {
        return cityInfoBackendService.batchInsertByExcel(file);
    }
}
